<?php

/**
 * Created by PhpStorm.
 * Author: ls
 * Time: 2023/10/17 16:44
 * Desc:
 */
class Request_Api_V2_Question extends Request_Api_V2_Base
{
    public function __construct($request_param)
    {
        parent::__construct($request_param);
    }

    public function question_list()
    {
        $this->rules = [
            ['type', ['digit', $this->rule_in_array([1, 2])]],
            ['article_id', ['digit', $this->rule_min(1)]],
            ['type_id', ['digit', $this->rule_min(1)]],
            ['page', ['digit', $this->rule_min(1)]],
            ['pagesize', ['digit', $this->rule_min(1)]],
        ];

        return $this;
    }

    public function add_question()
    {
        $this->validation->rule('mid', array('Rule_Member', 'need_member'));

        $question_type = $this->request_param['ques_type'];
        $rules         = [
            ['ques_type', ['not_empty', 'digit', $this->rule_in_array([0, 1])]],
            ['content', ['not_empty']],
            ['mobile', ['not_empty', 'phone']],
            ['captcha_key', ['not_empty']],
            ['code', ['not_empty']],
        ];

        if ($question_type == 1) {
            $rules[] = ['title', ['not_empty']];
        } else {
            $rules[] = ['article_id', ['digit', $this->rule_min(1)]];
            $rules[] = ['type_id', ['digit', $this->rule_min(1)]];
        }

        $this->rules = $rules;

        return $this;
    }


}